package xyz.renyumeng.xkm.dto.base;

import lombok.Builder;
import lombok.Data;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author renyumeng
 * @date Created in 8:46 2023/7/4
 */

public class SearchPage<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    private Integer current;

    private Integer total;

    private Boolean hasNext;



    private T data;

    public SearchPage(Integer current, Integer total, Boolean hasNext, T data) {
        this.current = current;
        this.total = total;
        this.hasNext = hasNext;
        this.data = data;
    }

    public Boolean getHasNext() {
        return hasNext;
    }

    @Override
    public String toString() {
        return "SearchPage{" +
                "current=" + current +
                ", total=" + total +
                ", hasNext=" + hasNext +
                ", data=" + data +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SearchPage<?> that = (SearchPage<?>) o;

        if (!Objects.equals(current, that.current)) return false;
        if (!Objects.equals(total, that.total)) return false;
        if (!Objects.equals(hasNext, that.hasNext)) return false;
        return Objects.equals(data, that.data);
    }

    @Override
    public int hashCode() {
        int result = current != null ? current.hashCode() : 0;
        result = 31 * result + (total != null ? total.hashCode() : 0);
        result = 31 * result + (hasNext != null ? hasNext.hashCode() : 0);
        result = 31 * result + (data != null ? data.hashCode() : 0);
        return result;
    }

    public SearchPage<T> setHasNext(Boolean hasNext) {
        this.hasNext = hasNext;
        return this;
    }

    public SearchPage() {
    }

    public SearchPage(Integer current, Integer total, T data) {
        this.current = current;
        this.total = total;
        this.data = data;
    }

    public Integer getCurrent() {
        return current;
    }

    public SearchPage<T> setCurrent(Integer current) {
        this.current = current;
        return this;
    }

    public Integer getTotal() {
        return total;
    }

    public SearchPage<T> setTotal(Integer total) {
        this.total = total;
        return this;
    }

    public T getData() {
        return data;
    }

    public SearchPage<T> setData(T data) {
        this.data = data;
        return this;
    }
}
